<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateNotesTable extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     */
    public function change()
    {
        $table = $this->table('notes', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_unicode_ci']);
        $table->addColumn('user_id', 'integer', ['null' => false, 'comment' => '用户ID'])
            ->addColumn('avatar', 'string', ['limit' => 255, 'null' => true, 'comment' => '头像地址'])
            ->addColumn('nickname', 'string', ['limit' => 50, 'null' => true, 'comment' => '昵称'])
            ->addColumn('gender', 'integer', ['limit' => 1, 'default' => 0, 'comment' => '性别: 0-未知, 1-男, 2-女'])
            ->addColumn('age', 'integer', ['limit' => 3, 'null' => true, 'comment' => '年龄'])
            ->addColumn('city', 'string', ['limit' => 50, 'null' => true, 'comment' => '城市'])
            ->addColumn('wechat_id', 'string', ['limit' => 50, 'null' => true, 'comment' => '微信号码'])
            ->addColumn('wechat_qrcode', 'string', ['limit' => 255, 'null' => true, 'comment' => '微信二维码'])
            ->addColumn('status', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '状态: 0-已抽取, 1-未抽取'])
            ->addColumn('create_time', 'timestamp', ['null' => true, 'comment' => '创建时间'])
            ->addColumn('update_time', 'timestamp', ['null' => true, 'comment' => '更新时间'])
            ->addIndex(['user_id'])
            ->addIndex(['gender'])
            ->addIndex(['status'])
            ->create();
    }
} 